package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author by jojo
 * @Date 2022/3/8
 * @Description
 */
@RestController
@RequestMapping("/api/v1")
@Api(value = "行为服务API",tags = "行为服务API")
public class BehaviorController {
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;
    @Autowired
    private ApReadBehaviorService apReadBehaviorService;
    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehaviorService;
    @Autowired
    private ApCollectionBehaviorService apCollectionBehaviorService;
    @Autowired
    private ApArticleBehaviorService apArticleBehaviorService;
    @ApiOperation("保存或取消 点赞行为")
    @PostMapping("/likes_behavior")
    public ResponseResult saveOrCancelLikes(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }
    @ApiOperation("保存阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult readByBehavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }
    @ApiOperation("保存或取消 不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikes(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }
    @ApiOperation("保存或取消 收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collection(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }
    @ApiOperation("查询文章行为相关信息")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult loadArticle(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
